package com.xxx.base.spring;

import org.springframework.context.ApplicationEvent;

/**
 * 可异步事件
 */
public class AsyncableEvent extends ApplicationEvent {
    /**
     * 默认异步
     */
    private boolean async = true;
    /**
     * Create a new ApplicationEvent.
     *
     * @param source the object on which the event initially occurred (never {@code null})
     */
    public AsyncableEvent(Object source) {
        super(source);
    }
    public AsyncableEvent(Object source, boolean async) {
        super(source);
        this.async = async;
    }

    public boolean isAsync() {
        return async;
    }

    /**
     * 同步执行事件
     */
    public final void sync() { async = false; }
}
